import { T_srv, Tsrv, ifs, ts, tvs, vue } from '@/services';
import { I_cmd, T_cmd } from './command';
import { N_RectifierSettings } from './type';

// 范围值存在问题
const sulfuric11Config = (): N_RectifierSettings.slotConfig => {
  return {
    tankID: 11,
    label: '硫酸11',
    name: 'sulfuric11',
    stages: [
      {
        stage: '阶段一',
        rampTime: {
          value: 0,
          code: 'my203'
        },
        holdTime: {
          value: 0,
          code: 'my208'
        },
        // 电压转换率100
        voltage: {
          value: 0,
          code: 'my233',
          conversionRate: 100
        }
      },
      {
        stage: '阶段二',
        rampTime: {
          value: 0,
          code: 'my204'
        },
        holdTime: {
          value: 0,
          code: 'my209'
        },
        voltage: {
          value: 0,
          code: 'my234',
          conversionRate: 100
        }
      },
      {
        stage: '阶段三',
        rampTime: {
          code: 'my205',
          value: 0
        },
        holdTime: {
          code: 'my210',
          value: 0
        },
        voltage: {
          code: 'my235',
          value: 0,
          conversionRate: 100
        }
      },
      {
        stage: '阶段四',
        rampTime: {
          code: 'my206',
          value: 0
        },
        holdTime: {
          code: 'my211',
          value: 0
        },
        voltage: {
          code: 'my236',
          value: 0,
          conversionRate: 100
        }
      },
      {
        stage: '阶段五',
        rampTime: {
          code: 'my207',
          value: 0
        },
        holdTime: {
          code: 'my212',
          value: 0
        },
        voltage: {
          code: 'my237',
          value: 0,
          conversionRate: 100
        }
      }
    ],
    modeInfo: {
      code: 'my797',
      value: false
    },
    configData: [
      {
        param: '浸泡时间',
        value: 0,
        unit: '秒',
        min: 0,
        max: 9999,
        code: 'my038'
      },
      // plc设定电压,转换率10
      {
        param: '设定电压',
        value: 0,
        unit: 'V',
        min: 0,
        max: 3000,
        code: 'myCRectifierSettings001',
        conversionRate: 10
      },
      {
        param: '设定电流',
        value: 0,
        unit: 'A',
        min: 0,
        max: 30000,
        code: 'myCRectifierSettings004',
        conversionRate: 1
      },
      {
        param: '整流器开关',
        value: true,
        unit: '',
        code: 'myCRectifierSettings007'
      }
    ]
  };
};

const sulfuric12Config = (): N_RectifierSettings.slotConfig => {
  return {
    tankID: 12,
    label: '硫酸12槽',
    name: 'sulfuric12',
    stages: [
      {
        stage: '阶段一',
        rampTime: {
          value: 0,
          code: 'my213'
        },
        holdTime: {
          value: 0,
          code: 'my218'
        },
        voltage: {
          value: 0,
          code: 'my243',
          conversionRate: 10
        }
      },
      {
        stage: '阶段二',
        rampTime: {
          value: 0,
          code: 'my214'
        },
        holdTime: {
          value: 0,
          code: 'my219'
        },
        voltage: {
          value: 0,
          code: 'my244',
          conversionRate: 10
        }
      },
      {
        stage: '阶段三',
        rampTime: {
          code: 'my215',
          value: 0
        },
        holdTime: {
          code: 'my220',
          value: 0
        },
        voltage: {
          code: 'my245',
          value: 0,
          conversionRate: 10
        }
      },
      {
        stage: '阶段四',
        rampTime: {
          code: 'my216',
          value: 0
        },
        holdTime: {
          code: 'my221',
          value: 0
        },
        voltage: {
          code: 'my246',
          value: 0,
          conversionRate: 10
        }
      },
      {
        stage: '阶段五',
        rampTime: {
          code: 'my217',
          value: 0
        },
        holdTime: {
          code: 'my222',
          value: 0
        },
        voltage: {
          code: 'my247',
          value: 0,
          conversionRate: 10
        }
      }
    ],
    modeInfo: {
      code: 'my798',
      value: false
    },
    configData: [
      {
        param: '浸泡时间',
        value: 0,
        unit: '秒',
        min: 0,
        max: 9999,
        code: 'my039'
      },
      {
        param: '设定电压',
        value: 0,
        unit: 'V',
        min: 0,
        max: 3000,
        code: 'myCRectifierSettings002',
        conversionRate: 10
      },
      // plc设定电流,只有硫酸阳极化12转换率10
      {
        param: '设定电流',
        value: 0,
        unit: 'A',
        min: 0,
        max: 3000,
        code: 'myCRectifierSettings005',
        conversionRate: 10
      },
      {
        param: '整流器开关',
        value: true,
        unit: '',
        code: 'myCRectifierSettings008'
      }
    ]
  };
};

const chromic15Config = (): N_RectifierSettings.slotConfig => {
  return {
    tankID: 15,
    label: '铬酸15槽',
    name: 'chromic15',
    stages: [
      {
        stage: '阶段一',
        rampTime: {
          value: 0,
          code: 'my223'
        },
        holdTime: {
          value: 0,
          code: 'my228'
        },
        voltage: {
          value: 0,
          code: 'my253',
          conversionRate: 10
        }
      },
      {
        stage: '阶段二',
        rampTime: {
          value: 0,
          code: 'my224'
        },
        holdTime: {
          value: 0,
          code: 'my229'
        },
        voltage: {
          value: 0,
          code: 'my254',
          conversionRate: 10
        }
      },
      {
        stage: '阶段三',
        rampTime: {
          code: 'my225',
          value: 0
        },
        holdTime: {
          code: 'my230',
          value: 0
        },
        voltage: {
          code: 'my255',
          value: 0,
          conversionRate: 10
        }
      },
      {
        stage: '阶段四',
        rampTime: {
          code: 'my226',
          value: 0
        },
        holdTime: {
          code: 'my231',
          value: 0
        },
        voltage: {
          code: 'my256',
          value: 0,
          conversionRate: 10
        }
      },
      {
        stage: '阶段五',
        rampTime: {
          code: 'my227',
          value: 0
        },
        holdTime: {
          code: 'my232',
          value: 0
        },
        voltage: {
          code: 'my257',
          value: 0,
          conversionRate: 10
        }
      }
    ],
    modeInfo: {
      code: 'my799',
      value: false
    },
    configData: [
      {
        param: '浸泡时间',
        value: 0,
        unit: '秒',
        min: 0,
        max: 9999,
        code: 'my040'
      },
      {
        param: '设定电压',
        value: 0,
        unit: 'V',
        min: 0,
        max: 3000,
        code: 'myCRectifierSettings003',
        conversionRate: 10
      },
      {
        param: '设定电流',
        value: 0,
        unit: 'A',
        min: 0,
        max: 30000,
        code: 'myCRectifierSettings006',
        conversionRate: 1
      },
      {
        param: '整流器开关',
        value: true,
        unit: '',
        code: 'myCRectifierSettings009'
      }
    ]
  };
};

// 运行参数无可用code
const tanksData = (): N_RectifierSettings.TankData[] => {
  return [
    {
      name: '硫酸11槽',
      key: 'sulfuric11',
      voltage: {
        value: 0,
        code: 'my126',
        conversionRate: 10
      },
      current: {
        value: 0,
        code: 'my129'
      },
      status: {
        value: true,
        code: 'myCRectifierSettings010'
      },
      totalSetTime: {
        value: 0,
        code: 'my400'
      },
      totalTime: {
        value: 0,
        code: 'my432'
      },
      totalStages: {
        value: 0,
        code: 'myCRectifierSettings013'
      },
      currentStage: {
        value: 0,
        code: 'myCRectifierSettings014'
      },
      stageTime: {
        value: 0,
        code: 'myCRectifierSettings015'
      }
    },
    {
      name: '硫酸12槽',
      key: 'sulfuric12',
      voltage: {
        value: 0,
        code: 'my127',
        conversionRate: 10
      },
      current: {
        value: 0,
        code: 'my130',
        conversionRate: 10
      },
      status: {
        value: true,
        code: 'myCRectifierSettings011'
      },
      totalSetTime: {
        value: 0,
        code: 'my401'
      },
      totalTime: {
        value: 0,
        code: 'my433'
      },
      totalStages: {
        value: 0,
        code: 'myCRectifierSettings016'
      },
      currentStage: {
        value: 0,
        code: 'myCRectifierSettings017'
      },
      stageTime: {
        value: 0,
        code: 'myCRectifierSettings018'
      }
    },
    {
      name: '铬酸15槽',
      key: 'chromic15',
      voltage: {
        value: 0,
        code: 'my128',
        conversionRate: 10
      },
      current: {
        value: 0,
        code: 'my131'
      },
      status: {
        value: true,
        code: 'myCRectifierSettings012'
      },
      totalSetTime: {
        value: 0,
        code: 'my404'
      },
      totalTime: {
        value: 0,
        code: 'my436'
      },
      totalStages: {
        value: 0,
        code: 'myCRectifierSettings019'
      },
      currentStage: {
        value: 0,
        code: 'myCRectifierSettings020'
      },
      stageTime: {
        value: 0,
        code: 'myCRectifierSettings021'
      }
    }
  ];
};

const chartData = () => ({
  voltage: [
    {
      name: '硫酸11槽',
      key: 'sulfuric11',
      active: true,
      code: 'my126',
      conversionRate: 10,
      // code: 'my093',
      values: [
        [Date.now(), 0],
        [Date.now() + 600000, 0]
      ]
    },
    {
      name: '硫酸12槽',
      key: 'sulfuric12',
      active: true,
      code: 'my127',
      conversionRate: 10,
      // code: 'my094',
      values: [
        [Date.now(), 0],
        [Date.now() + 600000, 0]
      ]
    },
    {
      name: '铬酸15槽',
      key: 'chromic15',
      active: true,
      code: 'my128',
      conversionRate: 10,
      // code: 'my095',
      values: [
        [Date.now(), 0],
        [Date.now() + 600000, 0]
      ]
    }
  ],
  current: [
    {
      name: '硫酸11槽',
      key: 'sulfuric11',
      active: true,
      code: 'my129',
      conversionRate: 1,
      values: [
        [Date.now(), 0],
        [Date.now() + 600000, 0]
      ]
    },
    {
      name: '硫酸12槽',
      key: 'sulfuric12',
      active: true,
      code: 'my130',
      conversionRate: 10,
      values: [
        [Date.now(), 0],
        [Date.now() + 600000, 0]
      ]
    },
    {
      name: '铬酸15槽',
      key: 'chromic15',
      conversionRate: 1,
      active: true,
      code: 'my131',
      values: [
        [Date.now(), 0],
        [Date.now() + 600000, 0]
      ]
    }
  ]
});

export {
  I_cmd,
  N_RectifierSettings,
  T_cmd,
  T_srv,
  Tsrv,
  chartData,
  chromic15Config,
  ifs,
  sulfuric11Config,
  sulfuric12Config,
  tanksData,
  ts,
  tvs,
  vue
};
